//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../../table

block form_items
  .field.thirteen.wide
    .ui.buttons.right.floated
      if page_perms.new
        button.ui.green.left.icon.labeled.button(type="button"
          onclick="window.location = '/p2/fund/new'") 新 增
          i.icon.plus
      else
        button#new.ui.green.icon.button.disabled(type="button")
          i.icon.ban(style="margin-top:1px; margin-right:2px;")
          | 新 增

      button.ui.orange.button(type="button"
        onclick="window.location = '/trstat/p2_fund_sum'") 资金变动汇总

      button.ui.blue.button(type="button"
        onclick="window.location = '/p2'") 返回助农取款

block thead
  tr
    th.center.aligned
    th.center.aligned 序 号
    th.center.aligned 创建时间
    th.center.aligned 资金池代号
    th.center.aligned 代理商名称
    th.center.aligned 联系人
    th.center.aligned 联系电话
    th.center.aligned 联系邮箱
    th.center.aligned 资金总额
    th.center.aligned 资金余额
    th.center.aligned 透支额度
    th.center.aligned 警戒线
    th.center.aligned 备 注
    th.center.aligned(colspan="3")

block tbody
  each record, index in records
    - var tr_color = ''
    - var warning = false
    if parseFloat(record.fund_remains) <= parseFloat(record.cordon)
      - tr_color = 'warning'
      - warning = true

    tr(class="#{tr_color}")
      td.center.aligned.collapsing
        if warning
          i.icon.lab.link.red(data-content="余额不足，请充值"
            data-variation="small very wide")

      td.center.aligned.collapsing
        if page_perms.edit
          a(href="/p2/fund/edit/#{record.uuid}")= record.serial
        else
          = record.serial
      td.center.aligned.collapsing= record.ctime.format('YYYY-MM-DD HH:mm:ss')
      td.center.aligned.collapsing= record.name
      td.center.aligned.collapsing= record.agent
      td.center.aligned.collapsing= record.contact
      td.center.aligned.collapsing= record.phone
      td.collapsing.center.aligned= record.email
      td.collapsing.center.aligned= fmtamt(record.fund_total)
      td.collapsing.center.aligned= fmtamt(record.fund_remains)
      td.collapsing.center.aligned= fmtamt(record.overdraw)
      td.collapsing.center.aligned= fmtamt(record.cordon)
      td= record.notes
      td.center.aligned.collapsing
        if page_perms.recharge
          i.icon.yen.link.green(data-content="充值"
            onclick="window.location = '/p2/fund/recharge/#{record.uuid}'")
        else
          i.icon.yen.link.green.disabled(data-content="充值")
      td.center.aligned.collapsing
        if page_perms.recharge
          i.icon.history.link.blue(data-content="查看充值历史"
            data-variation="small very wide"
            onclick="window.location = '/p2/fund/recharge/history/#{record.uuid}'")
        else
          i.icon.history.link.blue.disabled(data-content="查看充值历史")
      td.center.aligned.collapsing
        i.icon.bar.chart.link.pink(data-content="查看资金变动历史"
          data-variation="small very wide"
          onclick="window.location = '/p2/fund/alter/#{record.uuid}'")
